﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core.DatabaseHelpers;
using Core.Interfaces;

namespace Core.Domains
{
    class District:IDistrict
    {
        private string _name;
        private int _districtId;
        private List<IBuilding> _buildings;
        private bool _fromDB = false;

        public int DistrictId
        {
            get { return _districtId; }
            set { _districtId = value; }
        }

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public List<IBuilding> Buildings
        {
            get { return _buildings; }
            set { _buildings = value; }
        }

        public void ConstructIt(object[] record)
        {
            _districtId = int.Parse(record[0].ToString());
            _name = record[1].ToString();
            _fromDB = true;
        }

        public bool FromDatabase()
        {
            return _fromDB;
        }

        public string GetErrorByCode(int code)
        {
            if (code == 1451 || code == 547)
            {
                return "Существуют здания в этом районе";
            }
            return "";
        }


        public override string ToString()
        {
            return _name;
        }
       
    }
}
